package zj.it.bhne.gridengineeringsurvey.fragment;


import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.FileProvider;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.flyco.dialog.widget.NormalDialog;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.loader.ImageLoader;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

import java.io.File;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;

import zj.it.bhne.gridengineeringsurvey.MyApplication;
import zj.it.bhne.gridengineeringsurvey.R;
import zj.it.bhne.gridengineeringsurvey.activity.AddItemActivity;
import zj.it.bhne.gridengineeringsurvey.activity.CaptureActivity;
import zj.it.bhne.gridengineeringsurvey.activity.DetailsActivity;
import zj.it.bhne.gridengineeringsurvey.activity.FileManagerActivity;
import zj.it.bhne.gridengineeringsurvey.activity.ItemActivity;
import zj.it.bhne.gridengineeringsurvey.activity.MapActivity;
import zj.it.bhne.gridengineeringsurvey.activity.OfflineDemo;
import zj.it.bhne.gridengineeringsurvey.activity.OnlineDetailsActivity;
import zj.it.bhne.gridengineeringsurvey.entity.VersionBean;
import zj.it.bhne.gridengineeringsurvey.entity.greendao.Equipment;
import zj.it.bhne.gridengineeringsurvey.entity.greendao.Items;
import zj.it.bhne.gridengineeringsurvey.entity.greendao.Line;
import zj.it.bhne.gridengineeringsurvey.entity.greendao.Online;
import zj.it.bhne.gridengineeringsurvey.entity.greendao.Photos;
import zj.it.bhne.gridengineeringsurvey.entity.greendao.Points;
import zj.it.bhne.gridengineeringsurvey.myutils.ExportUnit;
import zj.it.bhne.gridengineeringsurvey.myutils.HttpConfig;
import zj.it.bhne.gridengineeringsurvey.myutils.ThreadManager;
import zj.it.bhne.gridengineeringsurvey.myutils.greendao.EquipmentDao;
import zj.it.bhne.gridengineeringsurvey.myutils.greendao.ItemsDao;
import zj.it.bhne.gridengineeringsurvey.myutils.greendao.LineDao;
import zj.it.bhne.gridengineeringsurvey.myutils.greendao.OnlineDao;
import zj.it.bhne.gridengineeringsurvey.myutils.greendao.PhotosDao;
import zj.it.bhne.gridengineeringsurvey.myutils.greendao.PointsDao;

import static zj.it.bhne.gridengineeringsurvey.myutils.GetVersion.update;
import static zj.it.bhne.gridengineeringsurvey.myutils.MyUtils.getToast;
import static zj.it.bhne.gridengineeringsurvey.myutils.ThreadManager.getThreadPool;

/**
 * 项目首页中BottomActivity的第一个页面
 */
public class OneFragment extends Fragment implements View.OnClickListener {

    private static final int FILE_SELECT_CODE = 9;
    private static String[] PERMISSIONS_STORAGE = {
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE};
    private List<Integer> images = new ArrayList<>();
    private ListView one_listView;
    private MainAdapter adapter;
    private List<Items> list = new ArrayList<>();
    private List<Items> itemsList = new ArrayList<>();
    private TextView one_tv_count;
    private ProgressDialog mProgressDialog;
    @SuppressLint("HandlerLeak")
    private Handler mHandler = new Handler() {
        public void handleMessage(Message msg) {
            //若工作完成，取消动画，初始化界面
            mProgressDialog.cancel();
        }
    };
    /**
     * 线程
     */
    private Runnable mRunnable = () -> {
        //需要耗时的工作
        appUpdate();
        Message msg = mHandler.obtainMessage();
        msg.what = 1;
        mHandler.sendMessage(msg);
    };

    /**
     * 删除文件夹和文件夹里面的文件
     */
    public static boolean deleteDir(final String pPath) {
        File dir = new File(pPath);
        return deleteDirWihtFile(dir);
    }

    /**
     * 删除所有文件
     */
    public static boolean deleteDirWihtFile(File dir) {
        if (dir == null || !dir.exists() || !dir.isDirectory())
            return true;
        for (File file : dir.listFiles()) {
            if (file.isFile())
                file.delete(); // 删除所有文件
            else if (file.isDirectory())
                deleteDirWihtFile(file); // 递规的方式删除文件夹
        }
        return dir.delete();// 删除目录本身
    }

    //用Pull方式解析XML
    public static Boolean parseXMLWithPulls(String xmlData) {
        try {
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            XmlPullParser xmlPullParser = factory.newPullParser();
            //设置输入的内容
            xmlPullParser.setInput(new StringReader(xmlData));
            //获取当前解析事件，返回的是数字
            int eventType = xmlPullParser.getEventType();
            //保存内容
            String code;

            while (eventType != (XmlPullParser.END_DOCUMENT)) {
                String nodeName = xmlPullParser.getName();
                switch (eventType) {
                    //开始解析XML
                    case XmlPullParser.START_TAG: {
                        //nextText()用于获取结点内的具体内容
                        if ("date".equals(nodeName)) {
                            code = xmlPullParser.nextText();
                            if (code.equals("1"))
                                return true;
                        }

                    }
                    break;
                    //结束解析
                    case XmlPullParser.END_TAG: {
                    }
                    break;
                    default:
                        break;
                }
                //下一个
                eventType = xmlPullParser.next();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onResume() {

        try {
            initData();
            adapter = new MainAdapter(getContext(), list);
            one_listView.setAdapter(adapter);
            adapter.notifyDataSetChanged();
            listOnClick();
            one_tv_count.setText("当前共有 " + itemsList.size() + " 个项目");
        } catch (Exception e) {
            e.printStackTrace();
        }
        super.onResume();
    }

    /**
     * 获取数据库中存储的项目信息
     **/
    private void initData() {
        itemsList = MyApplication.getInstances().getItemsDao().queryBuilder().build().list();
        if (!list.isEmpty())
            list.clear();
        if (!itemsList.isEmpty()) {
            list.add(itemsList.get(itemsList.size() - 1));
        }
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_one, container, false);
        initView(view);
        return view;
    }

    /**
     * 版本更新
     */
    private void appUpdate() {
        SPUtils.getInstance().put("update","1");
        String version = HttpConfig.getVersion();
        ////Log.e("TAG", "appUpdate: " + version);
        if (version != null) {
            VersionBean versionBean = HttpConfig.parseXMLVersion(version);
            if (versionBean.isUpdate()) {
                update(versionBean.getUpdateUrl(), getActivity());
            }
        } else {
            ToastUtils.showShort("网络错误");
        }

    }

    @SuppressLint({"SetTextI18n", "ClickableViewAccessibility"})
    private void initView(View view) {
        images.add(R.drawable.a);
        images.add(R.drawable.a);
        images.add(R.drawable.a);
        Banner banner = view.findViewById(R.id.banner);
        //设置banner样式
        banner.setBannerStyle(BannerConfig.NUM_INDICATOR);
        //设置图片加载器
        banner.setImageLoader(new GlideImageLoader());
        //设置图片集合
        banner.setImages(images);
        //设置轮播时间
        banner.setDelayTime(4000);
        //banner设置方法全部调用完毕时最后调用
        banner.start();
        TextView one_btn_one = view.findViewById(R.id.one_btn_one);
        one_btn_one.setOnClickListener(this);
        TextView one_btn_two = view.findViewById(R.id.one_btn_two);
        one_btn_two.setOnClickListener(this);
        TextView one_btn_three = view.findViewById(R.id.one_btn_three);
        one_btn_three.setOnClickListener(this);
        TextView one_btn_four = view.findViewById(R.id.one_btn_four);
        one_btn_four.setOnClickListener(this);
        TextView one_btn_five = view.findViewById(R.id.one_btn_five);
        one_btn_five.setOnClickListener(this);
        TextView one_btn_six = view.findViewById(R.id.one_btn_six);
        one_btn_six.setOnClickListener(this);
        TextView one_btn_seven = view.findViewById(R.id.one_btn_seven);
        one_btn_seven.setOnClickListener(this);
        TextView one_btn_eight = view.findViewById(R.id.one_btn_eight);
        one_btn_eight.setOnClickListener(this);

        one_listView = view.findViewById(R.id.one_listView);

        one_tv_count = view.findViewById(R.id.one_tv_count);

        ImageButton activity_ib_back = view.findViewById(R.id.activity_ib_back);
        activity_ib_back.setOnClickListener(this);
        TextView activity_tv_title = view.findViewById(R.id.activity_tv_title);
        activity_tv_title.setOnClickListener(this);
        TextView activity_tv_save = view.findViewById(R.id.activity_tv_save);
        activity_tv_save.setOnClickListener(this);
        activity_ib_back.setVisibility(View.GONE);
        activity_tv_title.setText(getString(R.string.app_name));
        activity_tv_save.setVisibility(View.GONE);

        if (SPUtils.getInstance().getString("update")==null||"0".equals(SPUtils.getInstance().getString("update"))) {
            if (NetworkUtils.isConnected()) {
                mProgressDialog = new ProgressDialog(getContext());
                mProgressDialog.setMessage("正在检查更新,请稍等...");
                mProgressDialog.setCanceledOnTouchOutside(false);
                mProgressDialog.show();
                ThreadManager.ThreadPool threadPool = getThreadPool();
                threadPool.execute(mRunnable);
            } else {
                ToastUtils.showShort("网络无连接");
            }
        }

    }

    private void listOnClick() {
        one_listView.setOnItemClickListener((parent, view, position, id) -> {
            Items items = (Items) adapter.getItem(position);

            if (items.getState().equals("在线")) {
                //getToast(context, items.getName() + items.getId() + items.isCheck());
                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
                map.put("surverytaskid", items.getProjectId());
                String result = HttpConfig.callService("getProjectStatusInfo", map);

                if (parseXMLWithPulls(result)) {
                    ToastUtils.showShort("此项目已结束勘测");
                } else {
                    Intent intent = new Intent(getContext(), MapActivity.class);
                    intent.putExtra("name", items.getState());
                    intent.putExtra("id", items.getId());
                    startActivity(intent);
                }
            } else {
                Intent intent = new Intent(getContext(), MapActivity.class);
                intent.putExtra("name", items.getState());
                intent.putExtra("id", items.getId());
                startActivity(intent);
            }

        });
    }

    @SuppressLint("CommitTransaction")
    @Override
    public void onDestroy() {
        super.onDestroy();
        OneFragment fragment = new OneFragment();
        FragmentManager manager = getFragmentManager();
        assert manager != null;
        FragmentTransaction transaction = manager.beginTransaction();
        manager.beginTransaction().remove(fragment);
        transaction.hide(fragment);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.one_btn_one:
                List<Items> itemsList = MyApplication.getInstances().getItemsDao().queryBuilder().where(ItemsDao.Properties.Stop.eq("0")).build().list();
                if (itemsList.size() > 0) {
                    Intent intent = new Intent(getContext(), MapActivity.class);
                    intent.putExtra("name", itemsList.get(itemsList.size() - 1).getName());
                    intent.putExtra("id", itemsList.get(itemsList.size() - 1).getId());
                    startActivity(intent);
                } else {
                    getToast(getContext(), "当前没有项目");
                }
                break;
            case R.id.one_btn_two:
                startActivity(new Intent(getContext(), ItemActivity.class));
                break;
            case R.id.one_btn_three:
                //startActivity(new Intent(getContext(), BaiduOfflineMapActivity.class));
                startActivity(new Intent(getContext(), OfflineDemo.class));
                break;
            case R.id.one_btn_four:
                Intent intent = new Intent(getContext(), AddItemActivity.class);
                intent.putExtra("add_id", 1);
                startActivity(intent);
                break;
            case R.id.one_btn_five:
                startDialog(1, -100, "", "", "");
                break;
            case R.id.one_btn_six:
                if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(getActivity(), PERMISSIONS_STORAGE, 1111);
                }
                startActivity(new Intent(getActivity(), FileManagerActivity.class));
                /*Uri uri;
                File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
                        + "/bhne/");
                if (!file.exists() && !file.isDirectory()) {
                    file.mkdirs();
                }
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    //做一些处理
                    //获取uri
                    uri = FileProvider.getUriForFile(Objects.requireNonNull(getContext()), "zj.it.bhne.gridengineeringsurvey.fileprovider", file);
                } else {
                    //在版本低于此的时候，做一些处理
                    uri = Uri.fromFile(file);
                }

                Intent intents = new Intent(Intent.ACTION_GET_CONTENT);
                intents.setDataAndType(uri, "file/*");
                intents.addCategory(Intent.CATEGORY_OPENABLE);
                try {
                    startActivityForResult(Intent.createChooser(intents, "选择文件"), FILE_SELECT_CODE);
                } catch (ActivityNotFoundException ex) {
                    Toast.makeText(getContext(), "亲，木有文件管理器啊-_-!!", Toast.LENGTH_SHORT).show();
                }
*/

                break;
            case R.id.one_btn_seven:
                //getToast(getContext(), "版本" + getLocalVersion(Objects.requireNonNull(getContext())) + ".0");
                getToast(getContext(), "版本V1.0.180912");
                break;
            case R.id.one_btn_eight:
                startActivity(new Intent(getContext(), CaptureActivity.class));
                break;
        }
    }

    /**
     * 查看文件后选择进行回调上传
     */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        if (resultCode != Activity.RESULT_OK) {
            super.onActivityResult(requestCode, resultCode, data);
            return;
        }
        if (requestCode == FILE_SELECT_CODE) {
            Uri uri = data.getData();
            assert uri != null;
            File file = new File(uri.getPath() + data);
            Intent shareIntent = new Intent();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                //做一些处理

                shareIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(Objects.requireNonNull(getContext()), "zj.it.bhne.gridengineeringsurvey.fileprovider", file));
                shareIntent.setType("text/plain");

                //设置分享列表的标题，并且每次都显示分享列表
                Objects.requireNonNull(getContext()).startActivity(Intent.createChooser(shareIntent, "分享到"));

            } else {
                //在版本低于此的时候，做一些处理
                shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
                shareIntent.setType("text/plain");

                //设置分享列表的标题，并且每次都显示分享列表
                Objects.requireNonNull(getContext()).startActivity(Intent.createChooser(shareIntent, "分享到"));
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    /**
     * 删除设备对话框
     */
    private void startDialog(final int number, final long cid, final String name, final String state, final String type) {

        final NormalDialog dialog = new NormalDialog(getContext());
        dialog.content("您确定要删除吗?")//
                .style(NormalDialog.STYLE_TWO)//
                .btnNum(2)
                .title("删除提示")
                .btnText("取消", "删除")//
                .show();
        dialog.setOnBtnClickL(
                dialog::dismiss, () -> {
                    dialog.dismiss();
                    if (number == 1) {
                        if (deleteDir(Environment.getExternalStorageDirectory().getAbsolutePath()
                                + "/bhne/")) {
                            getToast(getContext(), "删除成功");
                        }
                    } else if (number == 2) {

                        if (state.equals("在线")) {
                            Online online = MyApplication.getInstances().getOnlineDao().queryBuilder().where(OnlineDao.Properties.Id.eq(type)).list().get(0);
                            online.setDown("no");
                            MyApplication.getInstances().getOnlineDao().update(online);
                            deleteItem(cid, name);
                        } else {
                            deleteItem(cid, name);
                        }


                    }
                });
    }

    @SuppressLint("SetTextI18n")
    private void deleteItem(long cid, String name) {
        //删除所有相关联的数据
        MyApplication.getInstances().getItemsDao().deleteByKey(cid);
        List<Points> pointsList = MyApplication.getInstances().getPointsDao().queryBuilder().where(PointsDao.Properties.Items_id.eq(cid)).build().list();
        for (int j = 0; j < pointsList.size(); j++) {
            MyApplication.getInstances().getPointsDao().delete(pointsList.get(j));
            try {
                List<Equipment> equipmentList = MyApplication.getInstances().getEquipmentDao().queryBuilder().where(EquipmentDao.Properties.Point_id.eq(pointsList.get(j).getId())).build().list();
                if (equipmentList.size() > 0)
                    for (int i = 0; i < equipmentList.size(); i++) {
                        MyApplication.getInstances().getEquipmentDao().delete(equipmentList.get(i));
                    }
                List<Photos> photosList = MyApplication.getInstances().getPhotosDao().queryBuilder().where(PhotosDao.Properties.Points_id.eq(pointsList.get(j).getId())).build().list();
                if (photosList.size() > 0)
                    for (int i = 0; i < photosList.size(); i++) {
                        MyApplication.getInstances().getPhotosDao().delete(photosList.get(i));
                    }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        List<Line> lines = MyApplication.getInstances().getLineDao().queryBuilder().where(LineDao.Properties.Item_id.eq(cid)).build().list();
        try {
            for (int i = 0; i < lines.size(); i++) {
                MyApplication.getInstances().getLineDao().delete(lines.get(i));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        initData();
        getToast(getContext(), "删除成功");
        adapter = new MainAdapter(getContext(), list);
        one_listView.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        one_tv_count.setText("当前共有 " + itemsList.size() + " 个项目");
        listOnClick();
        deleteDir(Environment.getExternalStorageDirectory().getAbsolutePath()
                + "/bhne/" + name);
        deleteDir(Environment.getExternalStorageDirectory().getAbsolutePath()
                + "/bhne/" + name + ".zip");
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }

    public class GlideImageLoader extends ImageLoader {
        @Override
        public void displayImage(Context context, Object path, ImageView imageView) {
            imageView.setImageResource((Integer) path);
        }

        //提供createImageView 方法，如果不用可以不重写这个方法，主要是方便自定义ImageView的创建
        @Override
        public ImageView createImageView(Context context) {
            //使用fresco，需要创建它提供的ImageView，当然你也可以用自己自定义的具有图片加载功能的ImageView
            return new ImageView(context);
        }
    }

    /**
     * 写在外面没法刷新试图
     **/
    private class MainAdapter extends BaseAdapter {
        @SuppressLint("SdCardPath")
        private Context context;
        private List<Items> list;
        private boolean isCheck = true;

        MainAdapter(Context context, List<Items> list) {
            this.context = context;
            this.list = list;
        }


        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @SuppressLint({"InflateParams", "SetTextI18n"})
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final ViewHolder viewHolder;
            if (convertView == null) {
                convertView = LayoutInflater.from(context).inflate(R.layout.activity_main_list, null);
                viewHolder = new ViewHolder(convertView);
                convertView.setTag(viewHolder);
            } else
                viewHolder = (ViewHolder) convertView.getTag();
            final Items items = list.get(position);
            viewHolder.main_cb_switch.setVisibility(View.GONE);
            viewHolder.main_tv_name.setText(items.getName() + "");
            viewHolder.main_tv_note.setText(items.getType() + "  " + items.getVoltage());
            viewHolder.main_tv_time.setText(items.getTime() + "");
            if ("在线".equals(items.getState())) {
                viewHolder.main_iv.setBackgroundResource(R.drawable.zaixian);
                ExportUnit exportUnit = new ExportUnit();
                viewHolder.main_tv_upload.setOnClickListener(v13 -> exportUnit.SetLocalExport(context, items.getId(), items.getName()));
                viewHolder.main_tv_up.setVisibility(View.VISIBLE);
                //viewHolder.main_tv_up.setOnClickListener(view -> );
                viewHolder.main_tv_up.setOnClickListener(v -> exportUnit.SetExport(context, items.getId(), items.getName()));
            } else {
                viewHolder.main_iv.setBackgroundResource(R.drawable.bendi);
                ExportUnit exportUnit = new ExportUnit();
                viewHolder.main_tv_upload.setOnClickListener(v13 -> exportUnit.SetLocalExport(context, items.getId(), items.getName()));
                viewHolder.main_tv_up.setVisibility(View.GONE);
            }
            viewHolder.main_ibt_details.setOnClickListener(v -> {
                if (isCheck) {
                    viewHolder.main_ibt_details.setImageResource(R.drawable.xiala);
                    viewHolder.bellow_layout.setVisibility(View.VISIBLE);
                    viewHolder.main_tv_details.setOnClickListener(v1 -> {
                        if (items.getIsCheck()) {
                            Intent intent = new Intent(getActivity(), DetailsActivity.class);
                            intent.putExtra("details", items.getId());
                            intent.putExtra("de_id", 2);
                            startActivity(intent);
                        } else {
                            Intent intent = new Intent(getActivity(), OnlineDetailsActivity.class);
                            intent.putExtra("details", items.getId());
                            intent.putExtra("de_id", 2);
                            startActivity(intent);
                        }

                    });
                    viewHolder.main_tv_delete.setOnClickListener(v12 -> {

                        startDialog(2, items.getId(), items.getName(), items.getState(), items.getType());

                            /*//删除之后刷新数据刷新视图显示
                            initData();
                            onResume();*/

                    });
                    isCheck = !isCheck;
                } else {
                    viewHolder.main_ibt_details.setImageResource(R.drawable.jinru);
                    viewHolder.bellow_layout.setVisibility(View.GONE);
                    isCheck = !isCheck;
                }
            });
            return convertView;
        }


        class ViewHolder {
            private TextView main_tv_name;
            private TextView main_tv_note;
            private ImageButton main_ibt_details;
            private TextView main_tv_time;
            private RelativeLayout bellow_layout;
            private TextView main_tv_upload;
            private TextView main_tv_up;
            private TextView main_tv_delete;
            private TextView main_tv_details;
            private CheckBox main_cb_switch;
            private ImageView main_iv;

            ViewHolder(View rootView) {
                this.main_tv_name = rootView.findViewById(R.id.main_tv_name);
                this.main_tv_note = rootView.findViewById(R.id.main_tv_note);
                this.main_ibt_details = rootView.findViewById(R.id.main_ibt_details);
                this.main_tv_time = rootView.findViewById(R.id.main_tv_time);
                this.bellow_layout = rootView.findViewById(R.id.below_layout);
                this.main_tv_upload = rootView.findViewById(R.id.main_tv_upload);
                this.main_tv_up = rootView.findViewById(R.id.main_tv_up);
                this.main_tv_delete = rootView.findViewById(R.id.main_tv_delete);
                this.main_tv_details = rootView.findViewById(R.id.main_tv_details);
                this.main_cb_switch = rootView.findViewById(R.id.main_cb_switch);
                this.main_iv = rootView.findViewById(R.id.main_iv);
            }

        }

    }
}


